<template>
  <div>
    <div class="zk" v-if="zk_data.isShow">
      <div class="title aui-ftn18 aui-font-weight aui-text-red">
        <div class="line aui-bg-red"></div>
        零元购
        <div class="line aui-bg-red"></div>
      </div>
      <van-row class="content">
        <!-- <section class="nine-article">
                <van-row>
                    <van-col span="12" class="nine-list" v-for="(item, index) in nine_data.items" :key="index">
                        <List :item="item" :cid="''"></List>
                    </van-col>
                </van-row>
                <div @click="initData()" class="aui-ftn14 aui-text-6 aui-text-center aui-padded-15" v-text="nine_data.text"></div>
            </section> -->
        <!-- <van-list
          v-model="zk_data.loading"
          :finished="zk_data.finished"
          finished-text="没有更多了"
          @load="fnInitZk"
        > -->
          <van-col
            span="12"
            class="list"
            style="transform: translate3d(0, 0, 0)"
            v-for="(item, index) in zk_data.data"
            :key="index"
            @click="fnOpenProduct(item.id)"
          >
            <div class="list-cont aui-bg-f">
              <div
                class="good-img"
                :style="{ backgroundImage: 'url(' + item.image + ')' }"
                v-lazy="item.image"
              >
              <div class="all-red" v-if="item.all_red > 0">
                    <i class="iconfont icon-zijin"></i>
                    <span>+{{item.all_red}}</span>
                </div>
              </div>
              <div
                class="cont"
                style="transform: translateZ(0) translate3d(0, 0, 0)"
              >
                <div
                  class="name aui-text-3 aui-ftn14 aui-font-weight van-ellipsis"
                  v-text="item.name"
                ></div>
                <div class="tag aui-ftn12 aui-text-a" style="text-decoration: line-through;">
                  ￥{{ item.price }}
                </div>
                <div class="bt aui-margin-t-15">
                  <button
                    class="aui-btn aui-ftn13 aui-text-f aui-bg-red"
                  >去申请</button>
                  <div class="number aui-ftn12 aui-text-a">
                    <span>{{item.num - item.exitnum}}</span>人申请
                  </div>
                </div>
              </div>
            </div>
          </van-col>
        <!-- </van-list> -->
      </van-row>
      <div
        class="aui-text-center aui-text-9 aui-ftn13 aui-padded-15"
        v-if="zk_data.isLoading && !zk_data.isTotal"
        v-cloak
      >
        —— 加载中 ——
      </div>
      <div
        class="aui-text-center aui-text-9 aui-ftn13 aui-padded-15"
        v-if="zk_data.isTotal"
        v-cloak
      >
        —— 到底啦 ——
      </div>
    </div>
  </div>
</template>

<script>
// import "@/styles/discount.css"
//   import Discount from '@/service/discount.js'
//   import List from '../../discount/components/nine.vue'
import home from "../../../service/home.js";
export default {
  data() {
    return {
      zk_data: {
        loading: false,
        finished: false,
        data: [],
        isShow: true,
        //   nine_data: {
        //     loading: false,
        //     finished: false,
        //     items: [],
        //     page: 0,
        //     disabled: false,
        //     refreshing: false,
        //     text: '数据加载中...'
      },
    };
  },
  // components: {
  //   List
  // },
  props: ["random"],
  watch: {
    random(newValue, oldValue) {
      this.fnLoadMore();
    },
  },
  mounted() {
    this.fnInitZk();
  },
  methods: {
    fnLoadMore: function () {
      this.zk_data = {
        loading: true,
        finished: false,
        data: [],
        isShow: true,
      };
      this.fnInitZk();
    },
    fnInitZk() {
      let { loading, finished, data, isShow } = this.zk_data;
        if (!loading && !finished) {
          loading = true;
          home.fnGetLYG({ p: 1, n: 100, isLoading: true, type: 1, category: '',sort: 2,downtype: '',puttype: '' }).then((res) => {
            // 加载状态结束
            loading = false;
            if (res) {
              if (res.status) {
                data = data.concat(res.data);
                let _arr = data.filter((item) => {
                  if (!item.exittime && item.exitnum > 0) return item;
                });
                data = _arr;
              } else {
                finished = true;
                isShow = false;
              }
              this.zk_data = {loading, finished, data, isShow}
            }
          });
        }
    },
    fnOpenProduct: function(id) {
        this.utils.fnOpenCommon(this, {name:'product', params: {id: id}})
    }
  },
};
</script>
<style>
</style>
